package com.shiroexploit.util;

import java.util.*;

public class Config {
    private static Config config;
    private List<String> keys;
    private List<PayloadType> gadgets;
    // 0 for Shiro550, 1 for Shiro721
    private int vulType = 0;
    // 0 for linux, 1 for windows
    private int platform = 0;
    // 0 for ceye.io, 1 for dnslog.cn, 2 for JRMP + dnslog.cn, 3 for echo
    private int checkMethod = 0;
    private boolean skipIfFound = true;
    private String ceyeDomain;
    private String ceyeToken;
    private String OOBServerAddress;
    private int HTTPServicePort;
    private int JRMPServicePort;
    private int fetchDNSLogResultDealy;
    private int JRMPRequestDelay;
    private HttpRequestInfo requestInfo;
    private String rememberMeCookieName;
    private String sessionId;
    private String dnsLogRecord;
    private String staticFilePath;

    public static Config getInstance(){
        //懒汉式
        if(config == null){
            config = new Config();

            //初始化key
            List<String> list = ConfigReader.loadKeys();

            if(list.size() == 0){
                list.add("kPH+bIxk5D2deZiIxcaaaA==");
            }

            config.setKeys(list);

            config.setGadgets(Arrays.asList(PayloadType.values()));

            String value = ConfigReader.getConfig("rememberMeCookieName");
            value = value == null ? "rememberMe" : value.trim();
            config.setRememberMeCookieName(value);

            String ceyeDomain = ConfigReader.getConfig("ceyeDomain");
            ceyeDomain = ceyeDomain == null ? "7wtusr.ceye.io" : ceyeDomain.trim();
            config.setCeyeDomain(ceyeDomain);

            String ceyeToken = ConfigReader.getConfig("ceyeToken");
            ceyeToken = ceyeToken == null ? "a78a1cb49d91fe09e01876078d1868b2" : ceyeToken.trim();
            config.setCeyeToken(ceyeToken);

            String fetchDNSLogResultDealy = ConfigReader.getConfig("fetchDNSLogResultDealy");
            int time = fetchDNSLogResultDealy == null ? 5 : Integer.parseInt(fetchDNSLogResultDealy.trim());
            config.setFetchDNSLogResultDealy(time);

            String JRMPRequestDelay = ConfigReader.getConfig("JRMPRequestDelay");
            time = JRMPRequestDelay == null ? 2 : Integer.parseInt(JRMPRequestDelay.trim());
            config.setJRMPRequestDelay(time);
        }

        return config;
    }

    public List<PayloadType> getGadgets() {
        return gadgets;
    }

    public void setGadgets(List<PayloadType> gadgets) {
        this.gadgets = gadgets;
    }

    public String getStaticFilePath() {
        return staticFilePath;
    }

    public void setStaticFilePath(String staticFilePath) {
        this.staticFilePath = staticFilePath;
    }

    public int getFetchDNSLogResultDealy() {
        return fetchDNSLogResultDealy;
    }

    public void setFetchDNSLogResultDealy(int fetchDNSLogResultDealy) {
        this.fetchDNSLogResultDealy = fetchDNSLogResultDealy;
    }

    public int getJRMPRequestDelay() {
        return JRMPRequestDelay;
    }

    public void setJRMPRequestDelay(int JRMPRequestDelay) {
        this.JRMPRequestDelay = JRMPRequestDelay;
    }

    public String getSessionId() {
        return sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    public String getDnsLogRecord() {
        return dnsLogRecord;
    }

    public void setDnsLogRecord(String dnsLogRecord) {
        this.dnsLogRecord = dnsLogRecord;
    }

    public String getRememberMeCookieName() {
        return rememberMeCookieName;
    }

    public void setRememberMeCookieName(String rememberMeCookieName) {
        this.rememberMeCookieName = rememberMeCookieName;
    }

    public HttpRequestInfo getRequestInfo() {
        return requestInfo;
    }

    public void setRequestInfo(HttpRequestInfo requestInfo) {
        this.requestInfo = requestInfo;
    }

    public int getCheckMethod() {
        return checkMethod;
    }

    public void setCheckMethod(int checkMethod) {
        this.checkMethod = checkMethod;
    }

    public List<String> getKeys() {
        return keys;
    }

    public void setKeys(List<String> keys) {
        this.keys = keys;
    }

    public int getVulType() {
        return vulType;
    }

    public void setVulType(int vulType) {
        this.vulType = vulType;
    }

    public boolean isSkipIfFound() {
        return skipIfFound;
    }

    public void setSkipIfFound(boolean skipIfFound) {
        this.skipIfFound = skipIfFound;
    }

    public String getCeyeDomain() {
        return ceyeDomain;
    }

    public String getCeyeToken() {
        return ceyeToken;
    }

    public void setCeyeDomain(String ceyeDomain) {
        this.ceyeDomain = ceyeDomain;
    }

    public void setCeyeToken(String ceyeToken) {
        this.ceyeToken = ceyeToken;
    }

    public String getOOBServerAddress() {
        return OOBServerAddress;
    }

    public void setOOBServerAddress(String OOBServerAddress) {
        this.OOBServerAddress = OOBServerAddress;
    }

    public int getHTTPServicePort() {
        return HTTPServicePort;
    }

    public void setHTTPServicePort(int HTTPServicePort) {
        this.HTTPServicePort = HTTPServicePort;
    }

    public int getJRMPServicePort() {
        return JRMPServicePort;
    }

    public void setJRMPServicePort(int JRMPServicePort) {
        this.JRMPServicePort = JRMPServicePort;
    }

    public int getPlatform() {
        return platform;
    }

    public void setPlatform(int platform) {
        this.platform = platform;
    }
}
